import urllib.request
import json
import jsonpath

url = "https://dianying.taobao.com/cityAction.json?activityId&_ksTS=1741227924091_120&jsoncallback=jsonp121&action=cityAction&n_s=new&event_submit_doGetAllRegion=true"

headers = {
    "User-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36",
    "Referer": "https://dianying.taobao.com/?spm=a1z21.3046609.city.1.32c0112aKfcK5A&city=110100",
}

request = urllib.request.Request(url, headers=headers)

response = urllib.request.urlopen(request)

content = response.read().decode("utf-8")

content = content[13:-2]

# file_path = "02_jsonpath_淘票票.json"
#
# with open(file_path, "w", encoding="utf-8") as fw:
#     fw.write(content)
#
# obj = json.load(open(file_path, "r", encoding="utf-8"))

obj = json.loads(content)

region_name_list = jsonpath.jsonpath(obj, "$..regionName")

print(region_name_list)